package com.dgut.demo.controller;

import com.dgut.demo.bean.EmployeesMessage;
import com.dgut.demo.service.EmployeesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther 虎
 * @Data 2021/2/4 23:13
 * @Version 1.0
 */
@RestController
public class EmployeesController {
    @Autowired
    private EmployeesService employeesService;

    @GetMapping("/getAllEmployeesMessage")
    public List<EmployeesMessage> getAllEmployeesMessage(){
        return employeesService.getAllEmployeesMessage();
    }

    @PostMapping("/addOneEmployeesMessage")
    public int addOneEmployeesMessage(String ename,String ephone,double esalary,String edepartment){
        EmployeesMessage employeesMessage = new EmployeesMessage();
        employeesMessage.setEname(ename);
        employeesMessage.setEphone(ephone);
        employeesMessage.setEsalary(esalary);
        employeesMessage.setEdepartment(edepartment);
        return employeesService.addOneEmployeesMessage(employeesMessage);
    }

    @DeleteMapping("/deleteOneEmployeesMessage")
    public int deleteOneEmployeesMessage(String eid){
        return employeesService.deleteOneEmployeesMessage(eid);
    }

    @PutMapping("/updateOneEmployeesMessage")
    public int updateOneEmployeesMessage(String eid,String ename,String ephone,double esalary,String edepartment){
        EmployeesMessage employeesMessage = new EmployeesMessage();
        employeesMessage.setEid(eid);
        employeesMessage.setEname(ename);
        employeesMessage.setEphone(ephone);
        employeesMessage.setEsalary(esalary);
        employeesMessage.setEdepartment(edepartment);
        return employeesService.updateOneEmployeesMessage(employeesMessage);
    }

    @GetMapping("/getOneEmployeesMessage")
    public EmployeesMessage getOneEmployeesMessage(String eid){
        return employeesService.getOneEmployeesMessage(eid);
    }

    @GetMapping("/getEmployeesMessageById")
    public List<EmployeesMessage> getEmployeesMessageById(String eid){
        return employeesService.getEmployeesMessageById(eid);
    }

    @GetMapping("/getEmployeesMessageByName")
    public List<EmployeesMessage> getEmployeesMessageByName(String ename){
        return employeesService.getEmployeesMessageByName(ename);
    }

    @GetMapping("/getEmployeesMessageByPhone")
    public List<EmployeesMessage> getEmployeesMessageByPhone(String ephone){
        return employeesService.getEmployeesMessageByPhone(ephone);
    }

    @GetMapping("/getEmployeesMessageByDepartment")
    public List<EmployeesMessage> getEmployeesMessageByDepartment(String edepartment){
        return employeesService.getEmployeesMessageByDepartment(edepartment);
    }
}
